--Api 表
/*
select * from SYS_Apis
select * from SYS_ApiM --M  Memo Main Manage
ReturnType
返回类型（类似返回值）
1 execSql
2 openSql
3 execProc(不带返回结果)
4 openProc(带返回结果集)
5 getList (使用getList sql 模板)
6 执行updata,delete 等，返回 操作的行数
*/

declare
  @ApiName varchar(50)='home.fileStat',
  @ReturnType int =5
--
--
delete from SYS_Apis where apiName=@ApiName
delete from SYS_ApiM where apiName=@ApiName
insert into SYS_ApiM([apiName],[name],[memo])
select @ApiName,'底稿和附件图表统计','底稿和附件图表统计'
insert into SYS_Apis(ApiName,paramsLen,params,ReturnType,sqlText)
select @ApiName,0,
'',
@ReturnType,
'
select isnull(dg_count, 0) as dg_count, isnull(fj_count, 0) as fj_count, dg_table.EditDate
from (select count(*) as dg_count, convert(varchar(100), EditDate, 23) EditDate
      from [#(zcbfid)]..sjdg
      where EditDate is not null
      group by convert(varchar(100), EditDate, 23)) dg_table
         full join (select count(*) as fj_count, convert(varchar(100), AddDate, 23) EditDate
                    from [#(zcbfid)]..sjdg_fj
                    group by convert(varchar(100), AddDate, 23)) fj_table on dg_table.EditDate = fj_table.EditDate;
'